package com.sishu.njrtsdms;

import org.jooq.codegen.GenerationTool;
import org.jooq.meta.jaxb.*;

public class GenMain {

    private static final String url = "jdbc:mysql://localhost:3306/njrts-dms_dev";

    private static final String username = "root";

    private static final String password = "root";

    private static final String driverClass = "com.mysql.cj.jdbc.Driver";


    public static void main(String[] args) throws Exception {
        Configuration configuration = new Configuration()
                .withJdbc(new Jdbc()
                        .withDriver(driverClass)
                        .withUrl(url)
//                        .withUrl("jdbc:mysql://127.0.0.1:3306/learn-jooq?serverTimezone=GMT%2B8")
                        .withUser(username)
                        .withPassword(password))
                .withGenerator(new Generator()
                        .withGenerate(new Generate()
                                .withPojos(Boolean.TRUE)
                                .withInterfaces(Boolean.TRUE)
                                .withDaos(Boolean.TRUE)
                                .withSpringAnnotations(Boolean.TRUE)
                        )
                        .withName("com.sishu.njrtsdms.jooq.generate.generator.CustomJavaGenerator")
                        .withStrategy(new Strategy().
                                withName("com.sishu.njrtsdms.jooq.generate.strategy" +
                                        ".CustomGeneratorStrategy"))
                        .withDatabase(new Database()
                                .withIncludeExcludeColumns(Boolean.TRUE)
                                .withExcludes("")
                                .withName("org.jooq.meta.mysql.MySQLDatabase")
//                                .withIncludes("s1_.*|s2_.*")
                                .withInputSchema("njrts-dms_dev"))
                        .withTarget(new Target()
                                .withPackageName("com.sishu.njrtsdms.jooq.codegen")
                                .withDirectory("/src/main/java")));

        GenerationTool.generate(configuration);
    }

}
